/**
 * Created by Neville Kadwa.
 */
package org.shiftone.cdep.model;

import org.apache.log4j.Logger;
import org.shiftone.cdep.util.NullIterator;
import org.shiftone.cdep.PackageManager;

import java.util.HashMap;
import java.util.Iterator;

public class PackageInfo
{
    public static final Logger LOG = Logger.getLogger(PackageManager.class);

    private int                   packageId   = 0;
    private String                packageName;
    private PackageInfo parent;

    private HashMap childList;

    public int getPackageId()
    {
        return packageId;
    }

    public void setPackageId(int packageId)
    {
        this.packageId = packageId;
    }

    public String getPackageName()
    {
        return packageName;
    }

    public void setPackageName(String packageName)
    {
        this.packageName = packageName;
    }

    public PackageInfo getParent()
    {
        return parent;
    }

    public void addChild(PackageInfo pkg)
    {
        if (childList == null)
            childList = new HashMap();

        childList.put(pkg.getPackageName(), pkg);
        pkg.parent = this;
    }

    public boolean hasChildren()
    {
        return (childList != null) && (childList.size() > 0);
    }

    public Iterator getChildrenIterator()
    {
        if (childList == null)
            return NullIterator.getNullIterator();

        return childList.values().iterator();
    }

}
